<?php defined('BASEPATH') or exit('No direct script access allowed');

class Crontab_m extends MY_Model {	
	function __construct(){
		parent::__construct();
	}
	
	///////////////////////////////////////////////////////////////////////////
	
	function reCalResult(){
		$rs1 = $this->db->query("SELECT * FROM ".TBL_BET." WHERE status='finished' AND result IS NULL")->result();
		foreach($rs1 as $item){
			$USER = $this->user_entity->init('id',$item->user_id);
			$USER->setCoin($USER->getCoin()+$item->stake);
			$USER->update();
			$this->db->where('id',$item->id)->update(TBL_BET,array('status'=>'cancelled','result'=>'cancelled'));
		}
		
		$rs2 = $this->db->query("SELECT * FROM ".TBL_BET_MANUAL." WHERE status='finished' AND result IS NULL")->result();
		foreach($rs2 as $item){
			$USER = $this->user_entity->init('id',$item->user_id);
			$USER->setCoin($USER->getCoin()+$item->stake);
			$USER->update();
			$this->db->where('id',$item->id)->update(TBL_BET,array('status'=>'cancelled','result'=>'cancelled'));
		}
		
		$rs3 = $this->db->query("SELECT * FROM ".TBL_BET_TOURNAMENT." WHERE status='finished' AND result IS NULL")->result();
		foreach($rs3 as $item){
			$USER = $this->user_entity->init('id',$item->user_id);
			$USER->setCoin($USER->getCoin()+$item->stake);
			$USER->update();
			$this->db->where('id',$item->id)->update(TBL_BET,array('status'=>'cancelled','result'=>'cancelled'));
		}
		
		$rs4 = $this->db->query("SELECT * FROM ".TBL_BET_MANUAL_TOURNAMENT." WHERE status='finished' AND result IS NULL")->result();
		foreach($rs4 as $item){
			$USER = $this->user_entity->init('id',$item->user_id);
			$USER->setCoin($USER->getCoin()+$item->stake);
			$USER->update();
			$this->db->where('id',$item->id)->update(TBL_BET,array('status'=>'cancelled','result'=>'cancelled'));
		}
	}
	///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	
	function notify(){
		//write_file('./uploads/timeexec.txt',sysDateTimeFormat( time(),"Y-m-d H:i:s" ).PHP_EOL, 'a+');//
		//$execedTime = intval( read_file('uploads/timeexec.txt') );
		//if($execedTime + 6 > time()) exit();
		$listUsers = $this->user_entity->getArrayListOfUser();
		$matches = $this->match_entity->getListMatchLiveNext5Mins();
		 //$str = serialize($matches);
		//mail('joss3js@gmail.com', $execedTime,$execedTime);  
		
		$arrayMobile = array();
		foreach($matches as $item){
			$MATCH = $this->match_entity->init('id', $item->id);
			foreach($listUsers as $user){
				//send email
				if( strtolower($user->country) != "india"){
					$this->email_sender->_sendEmailToUser_notifyMatchComing($user->id, $match_id = $MATCH->getId());
					//if($MATCH->getEmailNotifyEnable() == 'yes'){
					//}
				}else{
					//if($MATCH->getEmailNotifyEnable() == 'yes'){
					//}
					//if($MATCH->getSmsNotifyEnable() == 'yes'){
					//}
					
					$this->email_sender->_sendEmailToUser_notifyMatchComing($user->id, $match_id = $MATCH->getId());
					if( !in_array( $user->mobile,$arrayMobile ) ){
						$this->sendSMS($user->id, $match_id = $MATCH->getId());
						$arrayMobile[] = $user->mobile;
					}
				}
			}
		}
		
		$this->tournament_rank_update();
		$this->reCalResult();
		echo time();
	}
	
	function tournament_rank_update(){
		$tournament = $this->db->where("(status LIKE 'living') AND publish LIKE 'publish' AND is_finish LIKE 'no' ")
					->get(TBL_TOURNAMENT)->result();
		foreach($tournament as $item){
			$this->user_tournament_entity->reCalTournamentRank($item->id);
		}			
	}
	
	function feed_match_update(){
		$this->updateMatch();
		$this->scorelog();
	}
	
	function updateMatchFeedInfo($match_id){
		$MATCH = $this->match_entity->init('id', $match_id);
		if($MATCH->getFeedMatchId() AND $MATCH->getStatus() == 'living'){
			if( $MATCH->getFeedType() AND $MATCH->getFeedKey() AND $MATCH->getFeedMatchId()){
				if($MATCH->getFeedKey() != 'livescore'){
					$info = $this->feed->getFeedInfoWithMatchId($MATCH->getFeedType(),$MATCH->getFeedKey(),$MATCH->getFeedMatchId());
					if($info){
						$MATCH->setFeedType($info['type']);
						$MATCH->setFeedKey($info['key']);
						$MATCH->update();
					}
				}
			}
		}
	}
	
	function closed_match(){
	/**
		$matchArr = $this->db->
					where("(status LIKE 'closed') AND feed_category_id IS NOT NULL AND feed_match_id IS NOT NULL AND feed_search LIKE 'no'")
					->order_by('id','desc')
					->limit(1)
					->get(TBL_MATCH)->result();
		 
		foreach($matchArr as $item){
			$MATCH = $this->match_entity->init('id', $item->id);
			if( $MATCH->getFeedType() AND $MATCH->getFeedKey() AND $MATCH->getFeedMatchId()){
				$info = $this->feed->getFeedInfoWithClosedMatch($MATCH->getFeedType(),$MATCH->getFeedKey(),$MATCH->getFeedMatchId());
				if($info){
					$MATCH->setFeedType($info['type']);
					$MATCH->setFeedKey($info['key']);
				}	
				
			}
			$MATCH->setFeedSearch('yes');
			$MATCH->update();
		}	
	**/		
	}
	
	function findBattingTeam($match_id){
		$MATCH = $this->match_entity->init('id', $match_id);
		$currentMatchArray = $this->feed->getCurrentMatchInfo($MATCH->getFeedType(),$MATCH->getFeedKey(),$MATCH->getFeedMatchId());
		if(!$currentMatchArray){
			return null;
		}
		
		$home = strtolower( $currentMatchArray['localteam_name'] );
		$away = strtolower( $currentMatchArray['visitorteam_name'] );
		$comment = strtolower( $currentMatchArray['comment'] );
		
		$arraySituation = array('bat', 'lead by', 'trail by', 'win', 'require', 'trails', 'need');
		
		$team = '';
		$comment = str_replace( array($home, $away ), array('HOME', 'AWAY'), $comment );
		$comment = str_replace( array('field'), array('FIELD'), $comment);
		$comment = str_replace(	$arraySituation, 
								array('FOUND','FOUND','FOUND','FOUND','FOUND','FOUND','FOUND'), 
								$comment
							   );
		
		if(containsString("FIELD",$comment)){
			if(containsString('HOME',$comment)){
				$team = 'away';
			}else{
				$team = 'home';
			}
		}
		
		foreach($arraySituation as $val){
			if(containsString('FOUND',$comment)){
				if(containsString('HOME',$comment)){
					$team = 'home';
				}else{
					$team = 'away';
				}
			}
		}
		
		$MATCH->setBattingTeam($team);
		$MATCH->update();
		
		return $team;
	}
	
	function processBatsmanOfMatch($match_id){
		$MATCH = $this->match_entity->init('id', $match_id);
		$battingTeam = '';
	//	$battingTeam = $this->findBattingTeam($match_id);
		if($MATCH->getFeedKey() == 'livescore'){
			$battingTeam = $this->findBattingTeam($match_id);
		}else{
			$currentMatchArray = $this->feed->getCurrentMatchInfo($MATCH->getFeedType(),$MATCH->getFeedKey(),$MATCH->getFeedMatchId());	
			if($currentMatchArray){
				if($currentMatchArray['localteam_type'] == 'bat'){
					$battingTeam = 'home';
				}else{
					$battingTeam = 'away';
				}
			}
		}
		
		$tmp = array();
		if($battingTeam){
			if($battingTeam == 'home'){
				$homeArr = $this->feed->getBatsmanNotout($MATCH->getFeedType(),$MATCH->getFeedKey(),$MATCH->getFeedMatchId(),$team='home');
				foreach($homeArr as $item){
					$tmp[] = array('batsman' => $item['batsman'] , 'r' => $item['r'] , 'b' => $item['b']);
				}
			}else if($battingTeam == 'away'){
				$awayArr  = $this->feed->getBatsmanNotout($MATCH->getFeedType(),$MATCH->getFeedKey(),$MATCH->getFeedMatchId(),$team='away');
				foreach($awayArr as $item){
					$tmp[] = array('batsman' => $item['batsman'] , 'r' => $item['r'] , 'b' => $item['b']);
				}
			}
			
			if($tmp){
				$batmanArray = $tmp;
				$MATCH->setBatmanInfo(serialize($batmanArray));
				$MATCH->update();
			}
		}
		return $tmp;
	}
	
	function changeTeamNameByCode($comment, $match_id){
		$MATCH = $this->match_entity->init('id', $match_id);
		$HOME = clone_($this->team_entity->init('id',$MATCH->getHome()));
		$AWAY = clone_($this->team_entity->init('id',$MATCH->getAway()));
		
		$home_name = $HOME->getName();
		$home_code = $HOME->getCode();
		$away_name = $AWAY->getName();
		$away_code = $AWAY->getCode();
		
		$comment = str_replace( array($home_name,$away_name), array($home_code,$away_code), $comment );
		return $comment;
	}
	
	function updateMatch(){
		$matchArr = $this->db->
					where("(status LIKE 'living' OR status LIKE 'upcoming') AND feed_category_id IS NOT NULL AND feed_match_id IS NOT NULL")
					->get(TBL_MATCH)->result();
		foreach($matchArr as $item){
			$this->updateMatchFeedInfo($item->id);
			$MATCH = $this->match_entity->init('id', $item->id);
		
			$homeScoreArr = $this->feed->getScoresAttrArray($MATCH->getFeedType(),$MATCH->getFeedKey(),$MATCH->getFeedMatchId(),$team='home');
			if($homeScoreArr){
				$home_score = $homeScoreArr['score'];
				$home_wicket = $homeScoreArr['wicket'];
				$home_over = $homeScoreArr['over'];
				$MATCH->setHomeScore($home_score);
				$MATCH->setHomeWickets($home_wicket);
				$MATCH->setHomeOvers($home_over);
			}
			$awayScoreArr = $this->feed->getScoresAttrArray($MATCH->getFeedType(),$MATCH->getFeedKey(),$MATCH->getFeedMatchId(),$team='away');
			if($awayScoreArr){
				$away_score = $awayScoreArr['score'];
				$away_wicket = $awayScoreArr['wicket'];
				$away_over = $awayScoreArr['over'];
				$MATCH->setAwayScore($away_score);
				$MATCH->setAwayWickets($away_wicket);
				$MATCH->setAwayOvers($away_over);
			}
			$currentMatchArray = $this->feed->getCurrentMatchInfo($MATCH->getFeedType(),$MATCH->getFeedKey(),$MATCH->getFeedMatchId());
			if($currentMatchArray){
				/**
				if( $currentMatchArray['comment'] == 'Not started'){
					$currentMatchArray['comment'] = 'Match starts at';
				}
				if( $currentMatchArray['match_status'] == 'Not started'){
					$currentMatchArray['match_status'] = 'Match starts at';
				}
				**/
				if( $currentMatchArray['comment'] != $currentMatchArray['match_status']){
					$feed_status =  $this->changeTeamNameByCode( $currentMatchArray['comment'], $MATCH->getId() ).
								"<br/><span class='status-color'>Status:</span> ".$currentMatchArray['match_status'];
				}else{
					$feed_status =  "<span class='status-color'>Status:</span> ".$currentMatchArray['match_status'];
				}
				  
				$MATCH->setResult($feed_status);
				if( strpos( strtolower($currentMatchArray['match_status']), 'progress' ) !== false ){
					$MATCH->setPlaying('yes');
					$MATCH->update();
				}
				
				if($currentMatchArray['match_status'] == 'Finished'){
					$MATCH->setStatus('closed');
					$MATCH->setEndTime(time());
					$MATCH->setPlaying('no');
					
					$checkHistory = $this->db->where('id',$MATCH->getId())->get(TBL_MATCH_HISTORY)->result();
					if(! $checkHistory){
						$inningArray = $this->feed->getInning($type=$MATCH->getFeedType(),$key=$MATCH->getFeedKey(),$match_id_post=$MATCH->getFeedMatchId());
						$array_info = array('inningArray' => $inningArray, 'currentInfo' => $currentMatchArray);
						$this->db->set('id',$mid);
						$this->db->set('match_id',$MATCH->getFeedMatchId());
						$this->db->set('content',serialize($array_info));
						$this->db->insert(TBL_MATCH_HISTORY); 
					}
				}
			}	
			$MATCH->update();
			$this->processBatsmanOfMatch($MATCH->getId());
			
		}		
		return true;	
	}
	
	function scorelog(){
		$matchArr = $this->db->
					where("(status LIKE 'living') AND feed_category_id IS NOT NULL AND feed_match_id IS NOT NULL")
					->get(TBL_MATCH)->result();
		 			
		foreach($matchArr as $item){
			//$this->updateMatchFeedInfo($item->id);
			$MATCH = $this->match_entity->init('id', $item->id);
			$this->findBattingTeam($MATCH->getId());
			$overArray = $this->feed->getOverInfo($MATCH->getFeedType(),$MATCH->getFeedKey(),$MATCH->getFeedMatchId());
			 
			if($overArray){
				$keyIndexArray = array_keys($overArray);
				$selectRS = $this->db->where( array('match_id'=>$MATCH->getFeedMatchId()) )->get(TBL_SCORECARD)->result();//'type'=>$MATCH->getFeedType(),'key'=>$MATCH->getFeedKey(),
				$overIndexArray = array();
				foreach($selectRS as $obj){
					$overIndexArray[] = $obj->over_index;
				}
				
				$time =  time();
				$keyIndexArray = array_reverse($keyIndexArray);
				
				foreach($keyIndexArray as $k){
					if(in_array($k,$overIndexArray)){
						$this->db->set('datetime', $time++);
						$this->db->set('value', $overArray[$k]);
						$this->db->set('batting_team', $MATCH->getBattingTeam());
						$this->db->where( array('match_id'=>$MATCH->getFeedMatchId(),'over_index'=>$k) )->update(TBL_SCORECARD);
					}else{
						$this->db->set('value', $overArray[$k]);
						$this->db->set('type', $MATCH->getFeedType());
						$this->db->set('key', $MATCH->getFeedKey());
						$this->db->set('match_id', $MATCH->getFeedMatchId());
						$this->db->set('over_index', $k);
						$this->db->set('category_id', $MATCH->getFeedCategoryId());
						$this->db->set('datetime', $time++);
						$this->db->set('batting_team', $MATCH->getBattingTeam());
						$this->db->insert(TBL_SCORECARD);
					}
				}
			}
		}	
		return true;		
	}
	
	function updateMatchInfoRealTime($match_id){
		$execedTime = intval( read_file('./uploads/timeexeccr.txt') );
		if($execedTime + 15 > time()) { 
			exit();
		}else{
			write_file('./uploads/timeexeccr.txt',time());
		}
		
		$this->updateMatchFeedInfo($match_id);
		$MATCH = $this->match_entity->init('id', $match_id );
	
		$homeScoreArr = $this->feed->getScoresAttrArray($MATCH->getFeedType(),$MATCH->getFeedKey(),$MATCH->getFeedMatchId(),$team='home');
		if($homeScoreArr){
			$home_score = $homeScoreArr['score'];
			$home_wicket = $homeScoreArr['wicket'];
			$home_over = $homeScoreArr['over'];
			$MATCH->setHomeScore($home_score);
			$MATCH->setHomeWickets($home_wicket);
			$MATCH->setHomeOvers($home_over);
			$MATCH->update();
		}
		$awayScoreArr = $this->feed->getScoresAttrArray($MATCH->getFeedType(),$MATCH->getFeedKey(),$MATCH->getFeedMatchId(),$team='away');
		if($awayScoreArr){
			$away_score = $awayScoreArr['score'];
			$away_wicket = $awayScoreArr['wicket'];
			$away_over = $awayScoreArr['over'];
			$MATCH->setAwayScore($away_score);
			$MATCH->setAwayWickets($away_wicket);
			$MATCH->setAwayOvers($away_over);
			$MATCH->update();
		}
		$currentMatchArray = $this->feed->getCurrentMatchInfo($MATCH->getFeedType(),$MATCH->getFeedKey(),$MATCH->getFeedMatchId());
		if($currentMatchArray){
			/**
			if( $currentMatchArray['comment'] == 'Not started'){
				$currentMatchArray['comment'] = 'Match starts at';
			}
			**/
			if( $currentMatchArray['comment'] != $currentMatchArray['match_status']){
				$feed_status =  $this->changeTeamNameByCode( $currentMatchArray['comment'], $MATCH->getId() ).
							"<br/><span class='status-color'>Status:</span> ".$currentMatchArray['match_status'];
			}else{
				$feed_status =  "<span class='status-color'>Status:</span> ".$currentMatchArray['match_status'];
			}
			 
			$MATCH->setResult($feed_status);
			if( strpos( strtolower($currentMatchArray['match_status']), 'progress' ) !== false ){
				$MATCH->setPlaying('yes');
				$MATCH->update();
			}
			
			if($currentMatchArray['match_status'] == 'Finished'){
				$MATCH->setStatus('closed');
				$MATCH->setEndTime(time());
				$MATCH->setPlaying('no');
				
				$checkHistory = $this->db->where('id',$MATCH->getId())->get(TBL_MATCH_HISTORY)->result();
				if(! $checkHistory){
					$inningArray = $this->feed->getInning($type=$MATCH->getFeedType(),$key=$MATCH->getFeedKey(),$match_id_post=$MATCH->getFeedMatchId());
					$array_info = array('inningArray' => $inningArray, 'currentInfo' => $currentMatchArray);
					$this->db->set('id',$mid);
					$this->db->set('match_id',$MATCH->getFeedMatchId());
					$this->db->set('content',serialize($array_info));
					$this->db->insert(TBL_MATCH_HISTORY); 
				}
			}
			$HOME_TEAM = clone_( $this->team_entity->init('feed_id',$currentMatchArray['localteam_id']) );
			$AWAY_TEAM = clone_( $this->team_entity->init('feed_id',$currentMatchArray['visitorteam_id']) );
			$MATCH->setHome($HOME_TEAM->getId());
			$MATCH->setAway($AWAY_TEAM->getId());
			$MATCH->update();
		}	
		 
		$tmp = $this->processBatsmanOfMatch($MATCH->getId());
	
		/////////////////////////
		$this->findBattingTeam($MATCH->getId());
		$overArray = $this->feed->getOverInfo($MATCH->getFeedType(),$MATCH->getFeedKey(),$MATCH->getFeedMatchId());
	 	 
		if($overArray){
			$keyIndexArray = array_keys($overArray);
			$selectRS = $this->db->where( array('match_id'=>$MATCH->getFeedMatchId()) )->get(TBL_SCORECARD)->result();//'type'=>$MATCH->getFeedType(),'key'=>$MATCH->getFeedKey(),
			$overIndexArray = array();
			foreach($selectRS as $obj){
				$overIndexArray[] = $obj->over_index;
			}
			$time =  time();
			$keyIndexArray = array_reverse($keyIndexArray);
			foreach($keyIndexArray as $k){
				if(in_array($k,$overIndexArray)){
					$this->db->set('datetime',$time++);
					$this->db->set('value', $overArray[$k]);
					$this->db->set('batting_team', $MATCH->getBattingTeam());
					$this->db->where( array('match_id'=>$MATCH->getFeedMatchId(),'over_index'=>$k) )->update(TBL_SCORECARD);
				}else{
					$this->db->set('value', $overArray[$k]);
					$this->db->set('type', $MATCH->getFeedType());
					$this->db->set('key', $MATCH->getFeedKey());
					$this->db->set('match_id', $MATCH->getFeedMatchId());
					$this->db->set('over_index', $k);
					$this->db->set('category_id', $MATCH->getFeedCategoryId());
					$this->db->set('datetime', $time++);
					$this->db->set('batting_team', $MATCH->getBattingTeam());
					$this->db->insert(TBL_SCORECARD);
				}
			}
		}
		 
		//print_r($tmp);
		exit();
	}
	
	function commet_update(){
		$match_id = intval($_GET['mid']);
		$this->updateMatchInfoRealTime($match_id);
		
		$MATCH = $this->match_entity->init('id',$match_id);
		$score = $this->db->
			where( 'match_id',$MATCH->getFeedMatchId())
			->order_by('id','ASC')->get(TBL_SCORECARD)->result();
	
		if($score){
			$latestIndex = sizeof($score) - 1;
			$index = $score[$latestIndex]->over_index;
			$value = $score[$latestIndex]->value;
			$secondLatest = $latestIndex-1;
			$batmanArr = unserialize($MATCH->getBatmanInfo());
			
			$html = "
			<div id=\"match_scoreboard\">
			<div id=\"content-wrap-element\">
				<div class=\"item-element\">
					<span class=\"title-text\">". stringNumberTextFM($index). " Over:</span>
					<span class=\"value\">". $value."</span>
				</div>";
				
			if($secondLatest>= 0){
				$index = $score[$secondLatest]->over_index;
				$value = $score[$secondLatest]->value;
				$html .= "
					<div class=\"item-element\">
						<span class=\"title-text\">".stringNumberTextFM($index)." Over:</span>
						<span class=\"value\">". $value ."</span>
					</div>";
			}
				
			$html .= "<div class=\"item-element batsman_border\">";
			if(isset($batmanArr[0])){
				$html .= "<div class=\"item-half\">
							<span class=\"title-text batsman\">".$batmanArr[0]['batsman']."</span> 
							<div class=\"clrboth\"></div>
							<span class=\"value batsman\">".$batmanArr[0]['r'].'('.$batmanArr[0]['b'].')'."</span>
						</div>";
			}
			if(isset($batmanArr[1])){
				$html .= "<div class=\"item-half\">
							<span class=\"title-text batsman\">". $batmanArr[1]['batsman']."</span> 
							<div class=\"clrboth\"></div>
							<span class=\"value batsman\">".$batmanArr[1]['r'].'('.$batmanArr[1]['b'].')'."</span>
						</div>";
			}
			
			$html .= "</div>
						<div class=\"item-element batsman_border\">
							<div class=\"wrap-element\">
								<a href='javascript:void(0);' onclick=\"return view_full_scorecard(".$MATCH->getId().");\" >View Full Scorecard</a>
							</div>
						</div>
					</div>
				</div>";
			echo $html;	
			exit();	
		}	
		echo '';
		exit();
	}
	
	
	function sendSMS($userId, $match_id){
		$USER = clone_( $this->user_entity->init('id',$userId) );
		$MATCH = $this->match_entity->init('id', $match_id);
		
		$slug = "sms_notification_crontab";
		
		$template = $this->module_helper->getTemplateMail( $slug );
		
		$orgArr = array( "{###MATCH###}" );
		$rplArr = array( $MATCH->getTitle() );
		$body = str_replace( $orgArr , $rplArr , $template['body'] );
		
		$body = urlencode( strip_tags($body) ); 
		
		$foneNo = $USER->getMobile();
		//$senderID = "mVaayoo";
		//$url = "http://api.mVaayoo.com/mvaayooapi/MessageCompose?user=vignesh@sunclassifiedads.com:india008&senderID={$senderID}&receipientno={$foneNo}&dcs=0&msgtxt={$body}&state=4";
		
		//$this->get_content($url);
		sendSMS($foneNo, $body);		
	}
/**	
	function get_content($URL){
          $ch = curl_init();
          curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
          curl_setopt($ch, CURLOPT_URL, $URL);
          $data = curl_exec($ch);
          curl_close($ch);
          return $data;
     }
	 
	function testSMS(){
		$ch = curl_init();
		$user="vignesh@sunclassifiedads.com:india008";
		$receipientno= "9880217545,7899631103"; 
		$senderID="TEST SMS"; 
		$msgtxt= "HELLO THIS IS TEST SMS"; 
		curl_setopt($ch,CURLOPT_URL,  "http://api.mVaayoo.com/mvaayooapi/MessageCompose");
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
		curl_setopt($ch, CURLOPT_POST, 1);
		curl_setopt($ch, CURLOPT_POSTFIELDS, "user=$user&senderID=$senderID&receipientno=$receipientno&dcs=0&msgtxt=$msgtxt");
		$buffer = curl_exec($ch);
		if(empty ($buffer))
		{ echo " buffer is empty "; }
		else
		{ echo $buffer; } 
		curl_close($ch);
	} 
	**/
	
	//http://api.mvaayoo.com/mvaayooapi/MessageCompose?user=vignesh@sunclassifiedads.com:india008&senderID=mVaayoo&receipientno=9880228845&dcs=0&msgtxt=Hi%20There!&state=4 
//end class
}	